import logging
from datetime import timedelta

from redis import StrictRedis


class Config:
    DEBUG = True
    SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@127.0.0.1:3306/db_info_16" #数据库
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    REDIS_IP = "127.0.0.1"
    REDIS_PORT = "6379"
    SESSION_TYPE = "redis"
    SESSION_REDIS = StrictRedis(host=REDIS_IP, port=REDIS_PORT) # 这个是系统用的redis
    SESSION_USE_SIGNER = True  #加密
    SECRET_KEY = "Gz+O+ZC8Als+cXTcqvK0Ot/PUhWkh+hgheNHk8ZfwoXwD0QZjsMfFdLoX1MqRdGe"
    # SESSION_PERMANENT = True  #session 可以持久化
    PERMANENT_SESSION_LIFETIME = timedelta(days=77)
    #开启数据库自动提交
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True

# 开发环境
class DevelopConfig(Config):
    DEBUG = True
    LOG_LEVEL = logging.DEBUG

#上线模式
class ProductConfig(Config):
    DEBUG = False
    LOG_LEVEL = logging.ERROR

conf = {
    "dev":DevelopConfig,
    "pro":ProductConfig
}